home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 944 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. From: jdmorris@ix.netcom.com (Jason D. Morris)
  2. Message-ID: <3161eaa4.8216104@nntp.ix.netcom.com>
  3. X-Original-Date: Wed, 03 Apr 1996 03:10:16 GMT
  4. Path: in2.uu.net!bounce-back
  5. Date: 03 Apr 96 03:28:27 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: constness of private members and methods
  9. Organization: Netcom
  10. References: <m0u3992-000GcEC@7.kurahaupo.gen.nz>
  11. X-Netcom-Date: Tue Apr 02  9:10:18 PM CST 1996
  12. X-Newsreader: Forte Agent .99d/32.182
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMWHwiuEDnX0m9pzZAQEZEQF/SdEOhOpnn4JH2fPLzr4lSku+g0vceN3N
  15.     gSeL1gJBH4dvDA5Q+3Q7W24eng7r7Noq
  16.     =HE2i
  17.  
  18. On 01 Apr 1996 10:39:46 PST, martin@kcbbs.gen.nz (Martin D Kealey)
  19. wrote:
  20.  
  21. >What are needed (to allow some function calls to be optimised
  22. >away) are two new keywords:
  23. >
  24. >  * "clean" which guarantees that the function doesn't modify
  25. >    objects that can only be reached as or through names
  26. >    in an outer scope - and in turn will not call any non-clean
  27. >    functions; and
  28. >
  29. >  * "pure" which guarantees that the function does not depend on
  30. >    the value of any outer scope object - and in turn will not
  31. >    call any non-pure function;
  32. >
  33. >To be fully useful, a function would be declared with both of
  34. >these attibutes and with all pointer or reference parameters
  35. >(including "this") declared "const".
  36. >
  37. >Anyone care to put this forward, or has it been discussed before?
  38.  
  39. Assuming you allow 'pure' and 'clean', the compiler would then have
  40. to check to make sure your functions were in fact 'pure' and 'clean'.
  41. If the compiler could do such checking as part of its array of
  42. optimizations, why not just do it for every function as
  43. part of a general optimization step?  If the compiler were to do
  44. no checking for the adherence to 'pure' and 'clean' modifiers, then
  45. such modifiers would essentially be a gentleman's contract.  Such
  46. a "contract" could be freely violated with potentially disastrous
  47. results; essentially making 'pure' and 'clean' meaningless.
  48.  
  49. Jason
  50. ---
  51. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  52. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  53. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  54. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  55. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  56.